#!/bin/bash

mkdir -p /data/hadoop/tmp
node=${hostname}

echo "current node: ${node} ,role ${node_role}"

/usr/sbin/sshd

if [[ ${node_role} == "Master" ]]
then
    [[ ! -e "/data/hadoop/init.done" ]] && /opt/hadoop/bin/hadoop namenode -format && touch /data/hadoop/init.done

    /opt/hadoop/sbin/start-all.sh

    cat ${HADOOP_HOME}/etc/hadoop/slaves|while read line;do
        ssh ${line} touch /data/hadoop/init.done
    done

# elif [[ ${node_role} == "Slave" ]]
# then
#     while  [[ ! -e "/data/hadoop/init.done" ]];
#     do
#     echo "waiting for master bootstrap"
#     sleep 5    
#     done
    
#     /opt/hadoop/sbin/start-all.sh
fi





tail -f 